﻿<?xml version="1.0" encoding="utf-8" ?>
<xs:schema targetNamespace="http://schemas.microsoft.com/sdm/Windows/ServerManager/Configuration/2007/1"
           xmlns="http://schemas.microsoft.com/sdm/Windows/ServerManager/Configuration/2007/1"
           xmlns:xs="http://www.w3.org/2001/XMLSchema"
           elementFormDefault="qualified">
    <!--
    
    Updated By:  Ryan D. Marshall (i|rdm)
       
    -->
  <!-- ======================================================================================= -->
  <!-- Root element for the input xml for install or remove. -->
  <!-- ======================================================================================= -->
  <xs:element name="ServerManagerConfiguration">
      <xs:annotation>
          <xs:documentation>
              Root element for the input xml for install or remove.
          </xs:documentation>
      </xs:annotation>
      <xs:complexType>
      <xs:choice minOccurs="1" maxOccurs="unbounded">
        <xs:element name="Role" type="FeatureType" minOccurs="0"/>
        <xs:element name="RoleService" type="FeatureType" minOccurs="0"/>
        <xs:element name="Feature" type="FeatureType" minOccurs="0"/>
        <xs:any namespace="##other" processContents="skip" minOccurs="0"/>
      </xs:choice>
      <xs:attribute name="Action" type="InstallationActionType" use="required"/>
      <xs:anyAttribute namespace="##other" processContents="skip"/>
    </xs:complexType>
  </xs:element>

  <!-- ======================================================================================= -->
  <!-- Root element for the results of an install or remove. -->
  <!-- ======================================================================================= -->
  <xs:element name="ServerManagerConfigurationResult">
      <xs:annotation>
          <xs:documentation>
              Root element for the results of an install or remove.
          </xs:documentation>
      </xs:annotation>
    <xs:complexType>
      <xs:choice minOccurs="1" maxOccurs="unbounded">
        <xs:element name="Role" type="FeatureResultType" minOccurs="0"/>
        <xs:element name="RoleService" type="FeatureResultType" minOccurs="0"/>
        <xs:element name="Feature" type="FeatureResultType" minOccurs="0"/>
        <xs:element name="Message" type="MessageType" minOccurs="0"/>
        <xs:any namespace="##other" processContents="skip" minOccurs="0"/>
      </xs:choice>
      <xs:attribute name="Action" type="InstallationActionType" use="required"/>
      <xs:attribute name="RequiresReboot" type="xs:boolean"/>
      <xs:attribute name="Success" type="xs:boolean"/>
      <xs:attributeGroup ref="CommonOutputAttributes"/>
      <xs:anyAttribute namespace="##other" processContents="skip"/>
    </xs:complexType>
  </xs:element>

  <!-- ======================================================================================= -->
  <!-- Root element for querying the roles and features that are installed. -->
  <!-- ======================================================================================= -->
  <xs:element name="ServerManagerConfigurationQuery">
      <xs:annotation>
          <xs:documentation>
              Root element for querying the roles and features that are installed.
          </xs:documentation>
      </xs:annotation>
      <xs:complexType>
      <xs:sequence>
        <xs:element name="Role" type="RoleQueryType" minOccurs="0" maxOccurs="unbounded"/>
        <xs:element name="Feature" type="FeatureQueryType" minOccurs="0" maxOccurs="unbounded"/>
        <xs:any namespace="##other" processContents="skip" minOccurs="0" maxOccurs="unbounded"/>
      </xs:sequence>
      <xs:attributeGroup ref="CommonOutputAttributes"/>
      <xs:anyAttribute namespace="##other" processContents="skip"/>
    </xs:complexType>
  </xs:element>

  <!-- ======================================================================================= -->
  <!-- Supporting types for the install (or remove) input xml. -->
  <!-- ======================================================================================= -->

  <!-- Definition for roles, role services, and features -->
  <xs:complexType name="FeatureType">
      <xs:annotation>
          <xs:documentation>
              Definition for roles, role services, and features.
          </xs:documentation>
      </xs:annotation>
      <xs:choice minOccurs="0" maxOccurs="unbounded">
      <xs:element name="Setting" type="SettingType"/>
      <xs:any namespace="##other" processContents="skip"/>
    </xs:choice>
    <xs:attribute name="Id" type="xs:string" use="required"/>
    <!-- InstallAllSubFeatures is ignored for features without subfeatures and during remove. -->
      <xs:attribute name="InstallAllSubFeatures" type="xs:boolean">
          <xs:annotation>
              <xs:documentation>
                  InstallAllSubFeatures is ignored for features without subfeatures and during remove.
              </xs:documentation>
          </xs:annotation>
      </xs:attribute>
    <xs:anyAttribute namespace="##other" processContents="skip"/>
  </xs:complexType>

  <!-- Definition for settings -->
  <xs:complexType name="SettingType">
      <xs:annotation>
          <xs:documentation>
              Definition for settings.
          </xs:documentation>
      </xs:annotation>
      <xs:simpleContent>
      <xs:extension base="xs:string">
        <xs:attribute name="Name"  use="required"/>
      </xs:extension>
    </xs:simpleContent>
  </xs:complexType>

  <!-- Install or Remove action -->
  <xs:simpleType name="InstallationActionType">
      <xs:annotation>
          <xs:documentation>
              Install or Remove action.
          </xs:documentation>
      </xs:annotation>
      <xs:restriction base="xs:string">
      <xs:enumeration value="Install"/>
      <xs:enumeration value="Remove"/>
    </xs:restriction>
  </xs:simpleType>

  <!-- ======================================================================================= -->
  <!-- Supporting types for the results output of an install or remove. -->
  <!-- ======================================================================================= -->

  <xs:complexType name="FeatureResultType">
      <xs:annotation>
          <xs:documentation>
              Supporting types for the results output of an install or remove.
          </xs:documentation>
      </xs:annotation>
      <xs:sequence>
      <xs:element name="Message" type="MessageType" minOccurs="0" maxOccurs="unbounded"/>
    </xs:sequence>
    <xs:attribute name="DisplayName" type="xs:string" use="required"/>
    <xs:attribute name="Success" type="xs:boolean"/>
    <xs:attribute name="RootParent" type="xs:string"/>
    <xs:attribute name="Id" type="xs:string"/>
    <xs:attribute name="RequiresReboot" type="xs:boolean"/>
    <xs:attribute name="Skipped" type="xs:boolean"/>
    <xs:attribute name="RequestedBy" type="RequestedByType"/>
  </xs:complexType>

  <xs:complexType name="MessageType">
    <xs:simpleContent>
      <xs:extension base="xs:string">
        <xs:attribute name="Level" use="required" type="LevelType"/>
        <xs:attribute name="Code" type="xs:integer"/>
      </xs:extension>
    </xs:simpleContent>
  </xs:complexType>

  <xs:simpleType name="LevelType">
    <xs:restriction base="xs:string">
      <xs:enumeration value="Error"/>
      <xs:enumeration value="Warning"/>
      <xs:enumeration value="Information"/>
    </xs:restriction>
  </xs:simpleType>

  <xs:simpleType name="RequestedByType">
    <xs:restriction base="xs:string">
      <xs:enumeration value="UserSpecified"/>
      <xs:enumeration value="Default"/>
      <xs:enumeration value="AllChildren"/>
      <xs:enumeration value="Dependency"/>
    </xs:restriction>
  </xs:simpleType>

  <xs:attributeGroup name="CommonOutputAttributes">
    <xs:attribute name="Time" type="xs:dateTime"/>
    <xs:attribute name="Sku" type="xs:string"/>
    <xs:attribute name="Language" type="xs:string"/>
    <xs:attribute name="Architecture" type="xs:string"/>
  </xs:attributeGroup>

  <!-- ======================================================================================= -->
  <!-- Supporting types for querying the roles and features that are installed. -->
  <!-- ======================================================================================= -->

  <xs:complexType name="RoleQueryType">
      <xs:annotation>
          <xs:documentation>
              Supporting types for querying the roles and features that are installed.
          </xs:documentation>
      </xs:annotation>
    <xs:sequence>
      <xs:element name="RoleService" type="RoleServiceQueryType" minOccurs="0" maxOccurs="unbounded"/>
      <!-- The Setting element currently only applies to Sharepoint -->
        <xs:element name="Setting" type="SettingQueryType" minOccurs="0" maxOccurs="unbounded">
            <xs:annotation>
                <xs:documentation>
                    The Setting element currently only applies to Sharepoint.
                </xs:documentation>
            </xs:annotation>
        </xs:element>
    </xs:sequence>
    <xs:attributeGroup ref="FeatureQueryAttributes"/>
  </xs:complexType>

  <xs:complexType name="RoleServiceQueryType">
    <xs:sequence>
      <xs:element name="RoleService" type="RoleServiceQueryType" minOccurs="0" maxOccurs="unbounded"/>
    </xs:sequence>
    <xs:attributeGroup ref="FeatureQueryAttributes"/>
  </xs:complexType>

  <xs:complexType name="FeatureQueryType">
    <xs:sequence>
      <xs:element name="Feature" type="FeatureQueryType" minOccurs="0" maxOccurs="unbounded"/>          
    </xs:sequence>
    <xs:attributeGroup ref="FeatureQueryAttributes"/>
  </xs:complexType>

  <xs:complexType name="SettingQueryType">
    <xs:sequence>
      <xs:element name="Value" type="ValueQueryType" minOccurs="0" maxOccurs="unbounded"/>
    </xs:sequence>
    <xs:attribute name="Name" type="xs:string"/>
    <xs:attribute name="Description" type="xs:string"/>
  </xs:complexType>

  <xs:complexType name="ValueQueryType">
    <xs:attribute name="Name" type="xs:string"/>
    <xs:attribute name="Description" type="xs:string"/>
  </xs:complexType>

  <xs:attributeGroup name="FeatureQueryAttributes">
    <xs:attribute name="DisplayName" type="xs:string" use="required" />
    <xs:attribute name="Installed" type="xs:boolean" use="required"/>
    <xs:attribute name="Id" type="xs:string"/>
    <xs:attribute name="Default" type="xs:boolean"/>
  </xs:attributeGroup>

</xs:schema>
